/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author asall
 */
public class ValidationHist {
        
        static Connexion con= new Connexion();    
        
     public String getStatut(int idDiplome) {
		String res="statut validation hist";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select va.statut"
                                + " from diplome di, validation_historique va"
                                + " where di.id_dip=va.fid_dip and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("statut"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getDate(int idDiplome) {
		String res="date validation hist";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select va.d_validation"
                                + " from diplome di, validation_historique va"
                                + " where di.id_dip=va.fid_dip and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("d_validation"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getNomResponsable(int idDiplome) {
		String res="nom responsable";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.nom"
                                + " from diplome di, validation_historique va, personnel per"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("nom"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getNumResponsable(int idDiplome) {
		String res="num harpege responsable";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.num_harpege"
                                + " from diplome di, validation_historique va, personnel per"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("num_harpege"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getPrenomResponsable(int idDiplome) {
		String res="prénom responsable";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.prenom"
                                + " from diplome di, validation_historique va, personnel per"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("prenom"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getCodeUfrResponsable(int idDiplome) {
		String res="code apoge ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.code_apogee"
                                + " from diplome di, validation_historique va, personnel per, composante cp"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and per.fid_comp=cp.id_comp"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("code_apogee"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getNomUfrResponsable(int idDiplome) {
		String res="nom ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.libelle_long"
                                + " from diplome di, validation_historique va, personnel per, composante cp"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and per.fid_comp=cp.id_comp"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_long"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
     public String getNomCourtUfrResponsable(int idDiplome) {
		String res="nom court ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.libelle_court"
                                + " from diplome di, validation_historique va, personnel per, composante cp"
                                + " where di.id_dip=va.fid_dip and va.fid_validateur=per.id_pers"
                                + " and per.fid_comp=cp.id_comp"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_court"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
}
